﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Text;

namespace Fierce.Utility.Helper
{
    /// <summary>
    /// 配置文件
    /// </summary>
    public static class ConfigHelper
    {
        private static IConfiguration configuration { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        static ConfigHelper()
        {
            var builder = new ConfigurationBuilder()
                .SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
                .AddJsonFile("appsettings.json");

            configuration = builder.Build();
        }

        /// <summary>
        /// 读取配置文件
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string GetByKey(string key)
        {
            return configuration[key];
        }

        /// <summary>
        /// 是否是开发模式
        /// </summary>
        public static bool IsDevelop
        {
            get
            {
                return Convert.ToBoolean(configuration["isDevelop"]);
            }
        }
    }
}